import axios from 'axios';
import { getToken } from './tokenUtil';
let request = axios.create({
	baseURL: import.meta.env.VITE_APP_BASE_API_PREFIX,
});
/**
 * 请求拦截器
 */
request.interceptors.request.use((config) => {
	// console.log('请求拦截器', config);
	config.headers.token = getToken();
	return config;
});
/**
 * 响应拦截器
 */
request.interceptors.response.use(
	(response) => {
		return response.data;
	},
	(error) => {
		ElMessage.error({
			message: error.message,
		});
		return Promise.reject(error);
	}
);
export default request;
